#include <stdlib.h>
#include <time.h>

template<typename T>
void PermuteRandom(T* vec,size_t n, int seed=-1)
{
	if(seed<0)
		srand((unsigned int)time(NULL));
	else
		srand(seed);
	for(size_t i=0; i<n-1; ++i)
	{
		int mod=n-i;
		int swapPos=rand()%mod;
		if(swapPos==i)
			continue;
		T temp=vec[i];
		vec[i]=vec[swapPos];
		vec[swapPos]=temp;
	}
}